package tree;

/**
 * Subtract node.
 * @author Natchanon Hongladaromp
 *
 */
public class SubtractNode implements Tree
{
	private Tree left;
	private Tree right;

	/**
	 * Constructs for this node.
	 * @param left
	 * @param right
	 */
	public SubtractNode(Tree left, Tree right)
	{
		this.left = left;
		this.right = right;
	}

	@Override
	public double value()
	{
		return left.value() - right.value();
	}

	@Override
	public String toString(int order)
	{
		String r = left.toString(1) + " - " + right.toString(1);

		if (order >= 1)
			return "(" + r + ")";
		else
			return r;
	}

	@Override
	public String toString()
	{
		return toString(-1);
	}
}
